package com.gnerv.battle.boot.framework.autoconfigure.core;

import com.gnerv.battle.boot.framework.core.tools.ApplicationContextTools;
import com.gnerv.battle.boot.framework.core.service.AccountPasswordService;
import com.gnerv.battle.boot.framework.core.service.CurrentAccountService;
import jakarta.annotation.Nonnull;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeansException;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author Gnerv LiGen
 */
@Slf4j
@Configuration
@EnableConfigurationProperties
public class BattleFrameworkCoreAutoConfiguration implements ApplicationContextAware {

    @Override
    public void setApplicationContext(@Nonnull ApplicationContext applicationContext) throws BeansException {
        ApplicationContextTools.setApplicationContext(applicationContext);
    }

    @Bean
    @ConditionalOnMissingBean
    public AccountPasswordService accountPasswordService(){
        return new AccountPasswordService() {
            @Override
            public String encrypt(String source) {
                return "";
            }
        };
    }

    @Bean
    @ConditionalOnMissingBean
    public CurrentAccountService currentAccountService(){
        return new CurrentAccountService() {
            @Override
            public String username() {
                return "";
            }

            @Override
            public String ukId() {
                return "";
            }

            @Override
            public String tenantUkId() {
                return "";
            }
        };
    }

}
